Skip to content

Export an in-process LiteRT marker from the runtime bridge - #115

Merged
leehack merged 1 commit into
mainfrom
runtime-capability-marker
Nov 8, 2026
Merged

leehack merged 1 commit into
mainfrom
runtime-capability-marker

Conversation

@leehack

@leehack leehack commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Adds int32_t litert_lm_native_in_process_litert_abi_version(void) to the LiteRtLmBridge exports on every platform, so consumers can tell runtimes whose LiteRT-LM → LiteRT external-weight handoff is ABI-valid from the v0.16–v0.19.1 Linux/Windows hosts that load upstream's prebuilt libLiteRt (#111). Today a consumer can't: v0.19.0, v0.19.1 and v0.19.1-1 all report upstream C API 1.0 (llamadart#1795).

Contract

Value Meaning
1 LiteRT compiled into the runtime; the build verified the binary imports no separate libLiteRt
0 Not established (every build before v0.19)
missing Runtime predates the marker; treat as 0
  • Every v0.19+ source build reports 1 on all platforms. Unknown future values must be rejected.
  • Additive bridge export only; no existing symbol, signature or upstream C API changes. It is not an upstream C API minor bump: litert_lm_get_api_version stays upstream's.
  • Releases through v0.19.1-1 lack it. v0.19.1-1 already links LiteRT in-process, so a consumer that must accept it identifies it another way (e.g. a pinned checksum).

Documented in docs/platform_strategy.md.

Changes

  • Bridge: new export, selected by --define=litert_lm_in_process_litert=true (→ LITERT_LM_IN_PROCESS_LITERT), which build_upstream_runtime.py passes for v0.19+.
  • The linkage check now covers every platform the marker claims: ELF (Linux, Android), PE (Windows) and Mach-O (macOS, iOS, including LiteRt.framework). Before, it covered Linux and Windows only. Published v0.19.1-1 Android, macOS and iOS hosts were inspected and import no libLiteRt.
  • litert_lm_finish_reason_smoke.py --abi-only also checks the marker value of the built Linux x64, macOS arm64 and Windows x64 runtimes in PR CI.
  • Follow-ups from #112 audit (desktop in-process LiteRT) #113 item 4: main()'s duplicated validation calls move into validate_runtime(). A new test fails on both build paths if the linkage check is dropped.
  • Follow-ups from #112 audit (desktop in-process LiteRT) #113 item 6: the CPU options decision message no longer points future tags at the prebuilt libLiteRt.

Validation

  • python3 -m unittest discover -s tools -p 'test_*.py': 445 OK, 3 skipped. diagnostics tests pass.
  • Mutation checks:
Mutation Result
Drop the linkage call from validate_runtime 2 failures
Drop either validate_runtime call in main() 1 failure each
Rename the Bazel define 16 failures
Return 0 from the marker under LITERT_LM_IN_PROCESS_LITERT C bridge test fails
  • Full native matrix: PR qualification on this head.

Refs #113. Items 1, 2 and 5 stay open (see the comment on #113). Item 3 was done in #114.

Consumers cannot tell C API 1.0 runtimes whose desktop hosts load the
prebuilt libLiteRt from ones that compile LiteRT in (#111), because both
report the same upstream API version. Every runtime now exports
litert_lm_native_in_process_litert_abi_version(): 1 for v0.19+ builds,
whose linkage the build now verifies on every platform, else 0.

Also covers the #113 linkage-check test gap and the stale CPU options
decision message.

Refs #113
@leehack
leehack merged commit 3e40b53 into main Nov 8, 2026
19 checks passed
leehack added a commit that referenced this pull request Nov 8, 2026
Covers the #115 audit follow-ups: main() exit code on marker mismatch, the
Bazel define name shared by BUILD.bazel and build_upstream_runtime.py, and the
marker's scope in the platform strategy and README.

Refs #113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant